<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        <!-- v-text、v-html -->
        <p>{{ msg }}</p>
        <p v-text="msg"></p>
        <p v-html="msg"></p>

        <!-- v-on -->
        <button v-on:click="show">按钮1</button>
        <button v-on:click="show()">按钮2</button>
        <button @click="show()">按钮3</button>
        <button @click="print(25)">按钮4</button>
        <button @click="print(name)">按钮5</button>

        <p>{{ age }}</p>
        <button @click="setAge">按钮6</button>
        <button @click="age=28">按钮7</button>

        <!-- v-show -->
        <button @click="flag=!flag">变</button>
        <!-- <p style="width: 100px; height: 100px; background: red;" v-show="flag">嘿嘿</p> -->
        <p style="width: 100px; height: 100px; background: red;" v-if="flag">嘿嘿</p>

        <!-- v-if、v-else-if、v-else -->
        <p v-if="age>=70">老年</p>
        <p v-else-if="age>=40">中年</p>
        <p v-else-if="age>=18">少年</p>
        <p v-else>童年</p>

        <!-- v-for -->
        <ul>
            <!-- <li v-for="(item,index) in names">{{ index }}-----{{ item }}</li> -->
            <li v-for="item in num">{{ item }}</li>
        </ul>

        <!-- v-bind -->
        <!-- <img v-bind:src="url" alt=""> -->
        <img :src="url" alt="">

    </div>

    <script>
        var vm = new Vue({
            el: '#app',
            data:{ // 数据仓库
                msg: '<h3>hello</h3>',
                name: 'tom',
                age: 18,
                flag: true,
                names: ['tom', 'jack', 'lucy'],
                num:5,
                url: 'https://search-operate.cdn.bcebos.com/e8cbce1d53432a6950071bf26b640e2b.gif'
            },
            methods: { // 方法仓库
                show: function(){
                    console.log(111)
                },
                print(args){ // 当对象的属性值为匿名函数时，可以简写
                    console.log(args)
                    console.log(this.name)
                    console.log(this) // 此处this表示当前Vue实例
                    console.log(this ==  vm)

                    this.show() // 调用方法
                },
                setAge(){
                    this.age = 28
                }
            }
        })
    </script>
</body>
</html>